<?php

  $hImg = imagecreatetruecolor(150,50);

  imagefill($hImg,0,0,getcolor($hImg));
  
  
   for($j=0;$j<499;$j++){
    $x = rand(80,200);   
    $y = rand(80,200);   
    $z = rand(80,200);   
    $color = imagecolorallocate($hImg,$x,$y,$z);
    $a = rand(0,150);
    $b = rand(0,50);
    $c = rand(0,150);
    $d = rand(0,50);
    imageline($hImg,$a,$b,$c,$d,$color);
    imagesetpixel($hImg,$a,$b,$color);
    }
    
    $str='1234567890';
    $code = substr(str_shuffle($str),4,4);
  for($i=0;$i<4;$i++){
    imagettftext($hImg,25,rand(-30,30),$i*30+20,rand(30,40),getcolor($hImg,true),'./arialbd.ttf',$code[$i]);
  }
  
  header('content-type:image/jpeg');
  imagejpeg($hImg);
  
  
  imagedestroy($hImg);
  
  
  
  function getcolor($hImg,$flag=false)
  {
      if($flag){
          return imagecolorallocate($hImg,rand(0,127),rand(0,127),rand(0,7));
      }else{
          return imagecolorallocate($hImg,rand(127,255),rand(127,255),rand(127,255));
      }
  }